package com.zzt.lotterysystem.common.exception;


import com.zzt.lotterysystem.common.errorcode.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created with IntelliJ IDEA.
 * Description
 * User: panda
 * Date: 2025-05-14
 * Time: 22:52
 */
// @Data 生成自己的 equals hashcode
// 不写 @EqualsAndHashCode(callSuper = true) 可能会出现问题
@Data
@EqualsAndHashCode(callSuper = true)
public class ControllerException extends RuntimeException{

    /**
     * 异常码
     * @see com.zzt.lotterysystem.common.errorcode.ControllerErrorCodeConstants
     */
    private Integer code;

    /**
     * 异常消息
     */
    private String msg;

    // 为了序列化
    public ControllerException() {
    }

    public ControllerException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ControllerException(ErrorCode errorCode){
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }
}
